package com.example.socket.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.socket.mapper.ScheduleJobLogMapper;
import com.example.socket.model.PageUtils;
import com.example.socket.model.ScheduleJobLogEntity;
import com.example.socket.service.IScheduleJobLogService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;

/**
 * Created with IDEA
 * author:QinWei
 * Date:2019/5/20
 * Time:15:02
 */
@Service("scheduleJobLogService")
public class ScheduleJobLogServiceImpl extends ServiceImpl<ScheduleJobLogMapper, ScheduleJobLogEntity> implements IScheduleJobLogService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String jobId = (String) params.get("jobId");
        Page<ScheduleJobLogEntity> page = new PageUtils<ScheduleJobLogEntity>(params).getPage();
        QueryWrapper<ScheduleJobLogEntity> queryWrapper = new QueryWrapper<ScheduleJobLogEntity>().like(StringUtils.isNotBlank(jobId), "job_id", jobId).orderByDesc("log_id");
        List<ScheduleJobLogEntity> list = this.page(page, queryWrapper).getRecords();
        page.setRecords(list);
        return new PageUtils<ScheduleJobLogEntity>(page);
    }
}
